﻿using com.iot.core.annotation;
using com.iot.core.boot;
using com.iot.core.data;
using com.iot.core.data.entity;
using com.iot.core.infrastructure;
using com.iot.core.manager.htcls;
using com.iot.core.manager.htctl;
using com.iot.core.manager.id;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

namespace com.iot.ht.Controllers.hterror
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Tag(Name = "系统异常", Description ="")]
    public class HtErrorController : ControllerBase
    {         
         
        IRepository<HtError> baseMapper;
        public HtErrorController(IRepository<HtError> p1)
        {    
            baseMapper=p1;
        }


        [HttpPost]
        [Operation(Summary= "系统异常分页", Description ="" )]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task< Page<HtError> > PageAsync([FromBody] BasePageDtQto mm)
        {
             
            var q = baseMapper.GetAll();
            if (!string.IsNullOrWhiteSpace(mm.Dtb))
            {
                q = q.Where(a => a.CrtDt >= mm.GetDB());
            }
            if (!string.IsNullOrWhiteSpace(mm.Dte))
            {
                q = q.Where(a => a.CrtDt < mm.GetDE());
            }
            if (!string.IsNullOrEmpty(mm.Key))
            {
                q = q.Where(a => a.Url.Contains(mm.Key)
                    || a.Name.Contains(mm.Key)
                    || a.HtdeptName.Contains(mm.Key)
                );
            }
            var r =await baseMapper.PageAsync(q, mm);
            return r;
        }

         

    }
}
